package com.gupaoedu.vip.factory.abstr;

import com.gupaoedu.vip.factory.Drink;

/**
 * Created by zhaozhonghai on 2017/5/24.
 */
public abstract class AbstractFactory {
    protected abstract Drink getDrink();

    public Drink getDrink(String name){
        AbstractFactory factory=null;
        if ("cocaCola".equalsIgnoreCase(name)){
            factory=new CocaColaFactory();
        }else if ("pepsiCola".equalsIgnoreCase(name)){
            factory=new PepsiFactory();
        }else if ("sprite".equalsIgnoreCase(name)){
            factory=new SpriteFactory();
        }else {
            System.out.println("没有相应的生产工艺");
        }
        if (factory!=null){
            return factory.getDrink();
        }else {
            return null;
        }
    }
}
